package com.itheima.controller;

import com.itheima.config.RedisProperties;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @Resource
    private RedisProperties redisProperties;
    @RequestMapping("/findOrderByUserId/{username}")
    public List<Order> findOrderByUserId(@PathVariable("username") String username) {
        List<Order> orderList = orderService.findOrderByUserId(username);
        for (Order order : orderList) {
            System.out.println(order);
        }
        return orderList;
    }

    //用来测试配置中心是否配置成功
    @GetMapping("/hello")
    public RedisProperties disUserById(){
        return redisProperties;
    }
}
